

package com.hexinfo.dmpro.sparing.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hexinfo.dmpro.common.annotation.AnonymousAccess;
import com.hexinfo.dmpro.sparing.service.HotStandbyLogSourceService;
import org.springframework.http.ResponseEntity;
import com.hexinfo.dmpro.sparing.model.HotStandbyLogSource;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;


/**
 * 热备源级日志分析表
 *
 * @author zax
 * @date 2023-11-18 14:24:10
 */
@RestController
@AllArgsConstructor
@RequestMapping("/api/hotstandbylogsource" )
@Api(value = "hotstandbylogsource", tags = "热备源级日志分析表管理")
public class HotStandbyLogSourceController {

    private final HotStandbyLogSourceService hotStandbyLogSourceService;

    /**
     * 分页查询
     * @param page 分页对象
     * @param hotStandbyLogSource 热备源级日志分析表
     * WrapperEnhancer.like(hotStandbyLogSource); //自动拼接存在值sql的方法
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/page" )
    @AnonymousAccess
    public ResponseEntity<Object> getHotStandbyLogSourcePage(Page page, HotStandbyLogSource hotStandbyLogSource) {
        return ResponseEntity.ok(hotStandbyLogSourceService.queryList(page,hotStandbyLogSource));
    }

    /**
     * 分页查询 条件查询
     * @param page 分页对象
     * @param hotStandbyLogSource 热备源级日志分析表
     * WrapperEnhancer.like(hotStandbyLogSource); //自动拼接存在值sql的方法
     * @return
     */
    @ApiOperation(value = "分页查询", notes = "分页查询")
    @GetMapping("/getHotStandbyLogSources" )
    @AnonymousAccess
    public ResponseEntity<Object> getHotStandbyLogSources(Page page, HotStandbyLogSource hotStandbyLogSource) {
        return ResponseEntity.ok(hotStandbyLogSourceService.getHotStandbyLogSources(page,hotStandbyLogSource));
    }

    /**
     * 获取当天全部源的成功、失败、进行中数量
     * @return
     */
    @ApiOperation(value = "获取当天全部源的成功、失败、进行中数量", notes = "获取当天全部源的成功、失败、进行中数量")
    @GetMapping("/getStateAllNum" )
    @AnonymousAccess
    public ResponseEntity<Object> getStateAllNum() {
        return ResponseEntity.ok(hotStandbyLogSourceService.getStateAllNum());
    }


    /**
     * 通过id查询热备源级日志分析表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id查询", notes = "通过id查询")
    @GetMapping("/{id}" )
    public ResponseEntity<Object> getById(@PathVariable("id" ) String id) {
        return ResponseEntity.ok(hotStandbyLogSourceService.getById(id));
    }

    /**
     * 新增热备源级日志分析表
     * @param hotStandbyLogSource 热备源级日志分析表
     * @return R
     */
    @ApiOperation(value = "新增热备源级日志分析表", notes = "新增热备源级日志分析表")
    @PostMapping
    public ResponseEntity<Object> save(@RequestBody HotStandbyLogSource hotStandbyLogSource) {
        return ResponseEntity.ok(hotStandbyLogSourceService.save(hotStandbyLogSource));
    }

    /**
     * 修改热备源级日志分析表
     * @param hotStandbyLogSource 热备源级日志分析表
     * @return R
     */
    @ApiOperation(value = "修改热备源级日志分析表", notes = "修改热备源级日志分析表")
    @PutMapping
    public ResponseEntity<Object> updateById(@RequestBody HotStandbyLogSource hotStandbyLogSource) {
        return ResponseEntity.ok(hotStandbyLogSourceService.updateById(hotStandbyLogSource));
    }

    /**
     * 通过id删除热备源级日志分析表
     * @param id id
     * @return R
     */
    @ApiOperation(value = "通过id删除热备源级日志分析表", notes = "通过id删除热备源级日志分析表")
    @DeleteMapping("/{id}" )
    public ResponseEntity<Object> removeById(@PathVariable String id) {
        return ResponseEntity.ok(hotStandbyLogSourceService.removeById(id));
    }

}
